package com.jt.controller;

import com.jt.pojo.ItemCat;
import com.jt.pojo.ItemCatParam;
import com.jt.service.ItemCatParamService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/itemCatParam")
public class ItemCatParamController {
    @Autowired
    private ItemCatParamService itemCatParamService;
/** 实现商品分类参数查询
 * url：/findItemCatParamListByType?itemCatId=560&paramType=1
 * 参数：itemCatId   paramType
 * 返回值：SysResult
 */
    @GetMapping("/findItemCatParamListByType")
    public SysResult findItemCatParamListByType (ItemCatParam itemCatParam){
      List<ItemCatParam> catParamList =  itemCatParamService.findItemCatParamListByType(itemCatParam);
        return SysResult.success(catParamList);
    }

    /**
     * 实现商品参数修改
     * url：/updateItemCatParam
     * 参数：ItemCatParam
     * 返回值：SysResult 对象
     */
    @PutMapping("/updateItemCatParam")
    public SysResult updateItemCatParam (@RequestBody ItemCatParam itemCatParam){
       itemCatParamService.updateItemCatParam (itemCatParam);
        return SysResult.success();
    }

    /**
     * 实现商品参数新增
     * url：/addItemCatParam
     * 参数:itemCatParam
     * 返回值：SysResult
     */
    @PostMapping("/addItemCatParam")
    public SysResult addItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.addItemCatParam(itemCatParam);
        return SysResult.success();
    }

    /**
     * 实现商品参数删除
     * url:deleteItemCatParamById
     * 参数：paramId = 20
     * 返回值：SysResult对象
     */
    @DeleteMapping("/deleteItemCatParamById")
    public SysResult deleteItemCatParam(Integer paramId){
        itemCatParamService.deleteItemCatParam(paramId);
        return SysResult.success();
    }
}
